package base.day12;

import java.util.ArrayList;
import java.util.Scanner;

public class ScannerStudent {
    public static void main(String[] args) {
        //创建集合
        ArrayList<Student> al=new ArrayList();
        for (int i = 0; i < 3; i++) {
            //键盘录入
            Scanner sc=new Scanner(System.in);
            System.out.println("请输入姓名：");
            String name=sc.nextLine();
            System.out.println("请输入年龄：");
            int age=sc.nextInt();
            //添加进集合
            Student stu1=new Student(name,age);
            al.add(stu1);
        }
        for (int j = 0; j < al.size(); j++) {
            Student temp = al.get(j);
            System.out.println(temp.getName()+","+temp.getAge());
        }
    }
}
